#include "Context.hpp"

// 测试鸭子的飞行能力和叫声能力
void Test()
{
  // 定义飞行能力
  FlyRocketPowered *frp = new FlyRocketPowered();
  FlyWithWings *fww = new FlyWithWings();
  FlyNoWay *fnw = new FlyNoWay();

  // 定义叫声能力
  OnlyQuack *oq = new OnlyQuack();
  Squack *sq = new Squack();
  MuteQuack *mq = new MuteQuack();

  // 定义游泳能力
  SwimNoWay* snw = new SwimNoWay();
  SwimFast* sf = new SwimFast();

  // 橡皮鸭
  RubbyDuck *rdk = new RubbyDuck((FlyBehavior *)frp, (QuackBehavior *)sq, snw);
  // 马拉尔鸭
  MallarDuck *mdk = new MallarDuck((FlyBehavior *)fww, (QuackBehavior *)oq, sf);
  // 红头鸭
  RedHeadDuck *rhdk = new RedHeadDuck((FlyBehavior *)fnw, (QuackBehavior *)oq, sf);
  // 诱饵鸭
  DecoyDuck *ddk = new DecoyDuck((FlyBehavior *)fnw, (QuackBehavior *)mq, snw);

  // 外貌
  rdk->Display();
  // 飞行能力
  rdk->PerformFly();
  // 叫声能力
  rdk->PerformQuack();
  // 游泳能力
  rdk->PerformSwim();

  std::cout << std::endl;

  mdk->Display();
  mdk->PerformFly();
  mdk->PerformQuack();
  mdk->PerformSwim();

  std::cout << std::endl;

  rhdk->Display();
  rhdk->PerformFly();
  rhdk->PerformQuack();
  rhdk->PerformSwim();
  
  std::cout << std::endl;

  ddk->Display();
  ddk->PerformFly();
  ddk->PerformQuack();
  ddk->PerformSwim();
  
  // 动态设置飞行能力
  // rdk->SetterFly(fww);
  // 执行
  // rdk->PerformFly();


  delete frp, fww, fnw;
  delete oq, sq, mq;
  delete snw, sf;
  delete rdk, rhdk, ddk, mdk; 
}

int main()
{
  Test();

  return 0;
}
